// packageB/member/category/component/sort/sort.js
Component({
  /**
   * 组件的属性列表
   */
  options: {
    addGlobalClass: true,
  },
  properties: {
    comment_show:{
      type:Boolean,
      value:true
    },
    pluginType: {
      type:String,
      default:''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */

  methods: {
    toggle(e) {
      let idx = e.currentTarget.dataset.idx;
      let order_field,order_by = '';
      switch (idx) {
      case 1:
        this.setData({
          hascolor: 1
        });
        if (this.data.colorshow == '1_2') {
          this.setData({
            colorshow: '1_1'
          });
          order_field = 'comment_num';
          order_by = 'asc';
        } else {
          this.setData({
            colorshow: '1_2'
          });
          order_field = 'comment_num';
          order_by = 'desc';
        }
        break;
      case 2:
        this.setData({
          hascolor: 2
        });
        if (this.data.colorshow == '2_2') {
          this.setData({
            colorshow: '2_1',
          });
          order_field = 'show_sales';
          order_by = 'asc';
        } else {
          this.setData({
            colorshow: '2_2',
          });
          order_field = 'show_sales';
          order_by = 'desc';
        }
        break;
      case 3:
        this.setData({
          hascolor: 3,
        });
        if (this.data.colorshow == '3_2') {
          this.setData({
            colorshow: '3_1'
          });
          order_field = 'min_price';
          order_by = 'asc';
        } else {
          this.setData({
            colorshow: '3_2'
          });
          order_field = 'max_price';
          order_by = 'desc';
        }
        break;
      }
      this.triggerEvent('sortIn', {order_field: order_field,order_by: order_by});
    },
    init(){
      this.setData({
        colorshow:'',
        hascolor:''
      })
    },
    showbox(){
      this.triggerEvent('showscreen', {});
    }
  }
})
